
/**上传控件弹窗  fileLimit上传文件个数限制,name上传控件的name */
var openFileListWindow = function(fileLimit,name,projectName,isEdit){ 
	var id = mini.get("id").getValue();
	if(id==""){
		SaveFormDataForId(fileLimit,name,projectName,isEdit);
	}else{
		openBody(fileLimit,name,projectName,isEdit);
	}
	
}
/**保存数据以获取ID*/
function SaveFormDataForId(fileLimit,name,projectName,isEdit) {
	var json1 = mini.encode(GetFormData(form2));
	mini.get("htmlValue").setValue(json1);
	var json = mini.encode(GetFormData(form1));
	mini.mask({
        el: document.body,
        cls: 'mini-mask-loading',
        html: '正在保存信息...'
    }); 
	$.ajax({
		url : projectName+"/DymcformDisplayAdmin/saveFormData",
		type : 'post',
		contentType : "application/json; charset=utf-8",
		dataType : 'json',
		data : json,
		cache : false,
		success : function(data) {
			mini.unmask();
			if (data.status == '1') {
				id = data.result.id;
				mini.get("id").setValue(data.result.id);
				if(data.result.version){
					mini.get("version").setValue(data.result.version);
				}
				openBody(fileLimit,name,projectName,isEdit);
			} else if(data.status == '0') {
				mini.alert(data.message);
			} else {
				mini.alert("发生错误!");
			}
		},
		error : function(jqXHR, textStatus, errorThrown) {
		    mini.unmask();
			mini.alert(jqXHR.responseText);
		}
	});
}
function openBody(fileLimit,name,projectName,isEdit){
	mini.open({
        url: projectName+"/AttachmentAdmin/ListPage?tableName="+tableName+"&tableDataId="+mini.get("id").getValue()+"&columnName="+dymcformId+"&fileLimit="+fileLimit,
        title: "上传附件", width: 700, height: 500,
        onload: function () {
            var iframe = this.getIFrameEl();
            iframe.contentWindow.hideButton(isEdit);
        },
        ondestroy: function (action) {
        	 var iframe = this.getIFrameEl();
        	 var groupId = iframe.contentWindow.getGroupId();
        	 if(groupId){
        		 mini.getbyName(name).setValue(groupId);
        	 }
        }
    });
}